< previous page page_321 next page >

Page 321
e10a6a0a59f035e870d90cca05b85fce.gif
   ' Start above and to the left of the drawing area.
   wid = tile_image.Parent.ScaleX(tile_image.Width, _
         tile_image.Parent.ScaleMode, pic.ScaleMode)
   hgt = tile_image.Parent.ScaleY(tile_image.Height, _
         tile_image.Parent.ScaleMode, pic.ScaleMode)
   y = -hgt
   x1 = -wid
   x2 = x1 + rdx
   startx = x1

   ' Copy the tile until we're to the right and
   ' below the drawing area.
   Do While y <= pic.ScaleHeight
       x = startx
        Do While x <= pic.ScaleWidth
            ' Copy the mask with vbMergePaint.
            pic.PaintPicture mask_image.Picture, _
                x, y, , , , , , , vbMergePaint

            ' Copy the mask with vbSrcAnd. 
            pic.PaintPicture tile_image.Picture, _
                x, y, , , , , , ,  vbSrcAnd
            x = x + cdx
        Loop

        If startx = x1 Then
            startx = x2
        Else
             startx = x1
        End If
        y = y + rdy
    Loop
End Sub
Example program TileHex uses this routine to display several different tiles. Click a tile image to make the program tile its drawing area with that tile. The offsets for the bottom two tiles are set so that the tiles do not cover the whole draw area. They incorporate the background color into the pattern displayed.
Summary
The programs described in this chapter are mostly decorative. They produce interesting images you can use to make a program unique. The self-similar fractal programs also provide interesting examples of recursive programming. By calling themselves to produce different parts of a curve, routines such as the Hilbert and Sierpinski subroutines generate images of remarkable complexity with surprisingly little code.

 
< previous page page_321 next page >